package person.zhaiming.service.impl;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import person.zhaiming.commons.entities.Payment;
import person.zhaiming.dao.PaymentDao;
import person.zhaiming.service.PaymentService;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

/**
 * @program: zhaimingSpringCloud
 * @description:
 * @author: zhaiming
 * @create: 2020-11-30 14:20
 **/
@Service
public class PaymentServiceImpl implements PaymentService {

    @Resource
    private PaymentDao paymentDao;

    @Override
    public int create(Payment payment) {
        return paymentDao.create(payment);
    }

    @Override
    public Payment getPaymentById(Long id) {
        return paymentDao.getPaymentById(id);
    }

    @Override
    public String getInfo(@Param("id") Long id){
        return "线程池:"+Thread.currentThread().getName()+"\tid:" + id + "\t";
    }

    @Override
    public String getTimeoutInfo(@Param("id") Long id){
        try{
            TimeUnit.SECONDS.sleep(4);
        }catch(Exception e){
            e.printStackTrace();
        }
        return "线程池:"+Thread.currentThread().getName()+"\tgetTimeoutInfo id:" + id + "\t";
    }
}
